<template>
  <section class="oa-form__table">
    <h5>{{ approve.name }}</h5>
    <table cellpadding="0" cellspacing="0">
      <tr v-if="$route.query.from != 'new'">
        <td>事务编号</td>
        <td>
          {{ approve.name }}
          <span v-if="approve && approve.code">{{ approve.code }}</span>
        </td>
      </tr>
      <tr>
        <td>流程名称</td>
        <td>
          <span v-if="$route.query.from == 'new'">新建{{ approve.name }}</span>
          <span v-else>
            {{ approve.approve_name }}
          </span>
        </td>
      </tr>
      <tr>
        <td>申请事由</td>
        <td :title="reason"><el-input placeholder="申请事由" type="textarea" v-model="reason" :disabled="$route.query.from != 'new'"/></td>
      </tr>
    </table>
    <h3 class="oa-form__table-title">
      <span v-if="$route.query.from === 'new'">{{ approve.name }}</span>
      <span v-else>
        {{ approve.approve_name }}
      </span>
    </h3>
     <table class="achievement__tab" border="1">
      <tr>
        <td>工作职责</td>
        <td colspan="8">
          1、完成月度目标产值。（月度利润目标、视频投资回报率）<br/>
          2、视频包装、过审、评论、点赞维护。<br/>
          3、购物车掉车后续维护工作。<br/>
          4、抖音账号包装维护工作。<br/>
          5、保障公司账号每天都正常运营，配合。<br/>
          6、纠错工作：评论区以及点赞纠错，出错一次扣50元。<br/>
          7、完成月度目标产值，将按超出利润的 %，额外发放奖金。
        </td>
      </tr>
      <tr>
        <td>考核周期:</td>
        <td>
          <el-date-picker
            value-format="yyyy-MM-dd"
            type="date"
            v-model="applyTime"
            :disabled="$route.query.from !== 'new'"
            placeholder="考核周期">
          </el-date-picker>
        </td>
        <td>部门:</td>
        <td width="400">
          <el-select v-model="department" :disabled="$route.query.from != 'new'" placeholder="请选择">
            <el-option
              v-for="item in departments"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </td>
        <td>姓名:</td>
        <td>
          <el-select v-model="value" style="width:60%" :disabled="$route.query.from != 'new'" placeholder="请选择"  @change="selectStaff($event)">
            <el-option
              v-for="item in staff"
              :key="item.value"
              :label="item.label"
              :value="item">
            </el-option>
          </el-select>
        </td>
        <td>部门:</td>
        <td><el-input v-model="gangwei" :disabled="$route.query.from !== 'new'" placeholder="部门"/></td>
        <td></td>
      </tr>
      <tr>
        <td class="_name">考核指标</td>
        <td class="_name">指标定义</td>
        <td class="_name">权重</td>
        <td class="_name">评分说明</td>
        <td class="_name">数据来源</td>
        <td class="_name">评分标准</td>
        <td class="_name">自评</td>
        <td class="_name">主管评分</td>
        <td class="_name">实际得分</td>
      </tr>
     <tr>
        <td>业绩考核</td>
          <td>月度利润目标</td>
            <td>50%</td>
            <td>当月总利润目标，视频回报比率</td>
            <td>财务</td>
            <td>
              完成率≧100%-50分<br>
              100%&gt;完成率≥80%-40分<br>
              80%≥完成率&gt;60%-30分<br>
              60%≥完成率&gt;40%-20分<br>
              40%≥完成率&gt;20%-10分<br>
              20%≥完成率&gt;0%-0分</td>
            <td><el-input v-model="obj.a709" :disabled="obj.a709Flag" /></td>
            <td>财务计算</td>
            <td><el-input v-model="obj.a717" :disabled="obj.a717Flag" /></td>
      </tr>
       <tr>
        <td rowspan="6">工作职责</td>
        <td>账号购买</td>
        <td>10%</td>
        <td>账号购买，并保障日账号数量</td>
        <td>自评</td>
        <td>确保账号购买和使用，无法达成每次扣2分</td>
        <td><el-input v-model="obj.a710" :disabled="obj.a710Flag" /></td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a718" :disabled="obj.a718Flag" /></td>
      </tr>
       <tr>
        <td>账号维护</td>
        <td>10%</td>
        <td>账号细节包装维护/日常养号</td>
        <td>自评</td>
        <td>账号头像，简介，封面，商品橱窗细节维护，保证账号标签正确，出错一次扣2分。</td>
        <td><el-input v-model="obj.a711" :disabled="obj.a711Flag" /></td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a719" :disabled="obj.a719Flag" /></td>
      </tr>
       <tr>
        <td>视频维护</td>
        <td>5%</td>
        <td>包装、过审、点赞、评论</td>
        <td>自评</td>
        <td>完成每天视频的包装，包括评论区，以及点赞，保证视频评论数量不少于要求。</td>
        <td><el-input v-model="obj.a712" :disabled="obj.a712Flag" /></td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a720" :disabled="obj.a720Flag" /></td>
      </tr>
       <tr>
        <td>购物车维护</td>
        <td>10%</td>
        <td>购物车维护</td>
        <td>自评</td>
        <td>购物车维护，掉车3分钟内须马上删除视频，进行处理，超时处理一次扣5分</td>
        <td><el-input v-model="obj.a713" :disabled="obj.a713Flag" /></td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a721" :disabled="obj.a721Flag" /></td>
      </tr>
       <tr>
        <td>工作态度</td>
        <td>5%</td>
        <td>工作积极性</td>
        <td>自评</td>
        <td>无法达成每次扣2分</td>
        <td><el-input v-model="obj.a714" :disabled="obj.a714Flag" /></td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a722" :disabled="obj.a722Flag" /></td>
      </tr>
       <tr>
        <td>投放</td>
        <td>5%</td>
        <td>投放数据监测</td>
        <td>自评</td>
        <td>配合完成实时监控视频投放数据，并及时统计相应数据。实时的把消耗金额还有订单数量统计到表格，测品每半个小时统计一次，大跑每十五到二十分钟一次。未执行扣3分，出错扣5分。</td>
        <td><el-input v-model="obj.a715" :disabled="obj.a715Flag" /></td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a723" :disabled="obj.a723Flag" /></td>
      </tr>
       <tr>
        <td>公司制度执行</td>
        <td>遵守公司规章制度</td>
        <td>5%</td>
        <td>遵守公司规章制度及执行力、配合度</td>
        <td>林光坦</td>
        <td>对公司制度及公司文化的理解和执行（包括根据公司整体规划制定个人工作计划，合理安排个人各项工作时间，遵守公司各项制度、积极配合领导安排的工作事宜等）</td>
        <td><el-input v-model="obj.a716" :disabled="obj.a716Flag" /></td>
        <td>督导</td>
        <td><el-input v-model="obj.a724" :disabled="obj.a724Flag" /></td>
      </tr>
      <tr>
        <td colspan="7"></td>
        <td>自评:{{myScore}}</td>
        <td>综合考核率:{{otherScore}}</td>
      </tr>
    </table>
    <history :process="process"></history>
    <files></files>
  </section>
</template>
<script>
import mixin from '@/mixins/index.js'
import history from '../service/components/process'
import files from '../service/components/files'
import { sum } from '@/utils/domUtils.js'
// import { save, info, getAutoKey } from '@/api/oa/index.js'
const obj = {}
for (let i = 705; i <= 724; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
export default {
  mixins: [mixin],
  data () {
    return {
      reason: '',
      truename: '',
      department: '',
      flag: false,
      value: '',
      obj: JSON.parse(JSON.stringify(obj)),
      applyTime: '',
      gangwei: '',
      file_paths: [],
      file_names: [],
      field_ids: [],
      field_vals: [],
      autoField: []
    }
  },
  components: { history, files },
  props: ['curDepartment', 'userInfo', 'approve', 'staff', 'addDofield', 'departments', 'process'],
  computed: {
    uploadArr () {
      return this.$store.state.uploadArr
    },
    b1 () {
      const num = parseFloat((Number(this.obj.a213) + Number(this.obj.a214)) / 2).toFixed(2)
      return num
    },
    myScore () {
      const result = []
      for (let i = 709; i <= 716; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      return sum(result)
    },
    otherScore () {
      const result = []
      for (let i = 717; i <= 724; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      return sum(result)
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.obj = JSON.parse(JSON.stringify(obj))
      if (this.$route.query.from === 'new') {
        this.disabled = true
      } else {
        this.infoFunc()
      }
    })
  },
  methods: {
  }
}
</script>
